#ifndef TCP_ACCEPTOR_H
#define TCP_ACCEPTOR_H
#include "io_acceptor.h"
#include "tcp_acceptor.h"

#ifdef _USING_ACE
#include "./detail/ace_tcp_connection.h"
#include "./detail/ace_tcp_acceptor_impl.h"
#else 
#include "./detail/asio_tcp_connection.h"
#include "./detail/asio_tcp_acceptor_impl.h"
#endif //


namespace vpm
{
    namespace mina
    {
        using namespace detail;

        template <class Session = TcpSession, class SessionConfigPtr = TcpSessionConfigPtr > 
        class TcpAcceptor : public IoAcceptor
        {
            public:
                TcpAcceptor(TcpAcceptorConfigPtr config, IoHandler& handler):m_tcpService(config,handler)
                {

                }

                virtual void bind(const ServiceUrl & address)
                {
                    if (address.port != 0 )
                    {
                        m_tcpService.bind(address.port,address.host);
                    }		
                }

                virtual void unbind()
                {
                    m_tcpService.unbind();
                }

            private:
                TcpAcceptorImpl<TcpConnectionImpl<Session,SessionConfigPtr> > m_tcpService; 
        };
    }
}
#endif //TCP_ACCEPTOR_H

